﻿' ----------------------------------------------------------------------
'
' NodeCollection.vb
'
'   ... Classes
'
'   This class contains the implementation of a single folder.
'
' ----------------------------------------------------------------------
' version:  1.0.0.1
' today:    08/25/06  15:41:00
' ident:    "@(#)/dbfs/NodeCollection.vb 1.0 0.1 08/25/06 0 rjs"

Imports System.Collections.ObjectModel
Imports System.Xml
Imports System.Xml.Serialization


Namespace Dbfs

    Public Class NodeCollection
        Inherits KeyedCollection(Of String, FileSystemInfo)
        Implements IXmlSerializable


#Region " Constructors "
        Public Sub New()
            MyBase.New(Nothing, -1)
        End Sub
#End Region ' Constructors

#Region " Methods "
        Public Sub Append(ByVal nodeCollection As NodeCollection)
            For Each Item As FileSystemInfo In nodeCollection
                Add(Item)
            Next
        End Sub

        Public Sub Append(ByVal fsInfo() As FileSystemInfo)
            For Each Item As FileSystemInfo In fsInfo
                Add(Item)
            Next
        End Sub

        Public Sub Sort()
            Dim list As List(Of FileSystemInfo)
            list = Items()
            list.Sort()
        End Sub

        ''' <summary>
        ''' Extracts the key from the specified element.
        ''' </summary>
        ''' <param name="item">The element from which to extract the key.</param>
        ''' <returns>The key for the specified element.</returns>
        ''' <remarks></remarks>
        Protected Overrides Function GetKeyForItem(ByVal item As FileSystemInfo) As String
            Return item.Name
        End Function
#End Region ' Methods

#Region "IXmlSerializable Support"
        Public Function GetSchema() As System.Xml.Schema.XmlSchema Implements System.Xml.Serialization.IXmlSerializable.GetSchema
            Throw New System.NotImplementedException()
        End Function

        Public Sub ReadXml(ByVal reader As XmlReader) Implements System.Xml.Serialization.IXmlSerializable.ReadXml
            reader.ReadStartElement("NodeCollection")
            reader.ReadEndElement()
        End Sub

        Public Sub WriteXml(ByVal writer As XmlWriter) Implements System.Xml.Serialization.IXmlSerializable.WriteXml
            writer.WriteStartElement("NodeCollection")
            writer.WriteEndElement()
        End Sub
#End Region

    End Class

End Namespace

